﻿using System;
using System.Collections.Generic;
using System.Linq;

using PortalIntranet.DatabaseComponents;
using PortalIntranet.DatabaseComponents.Seguranca;
using PortalIntranet.ObjectComponents.WebParts.ConteudosWeb;
using PortalIntranet.DatabaseComponents.WebParts;
using PortalIntranet.BusinessComponents.Seguranca;
using PortalIntranet.DatabaseComponents.WebParts.ConteudosWeb;

namespace PortalIntranet.BusinessComponents.WebParts.ConteudosWeb
{
	public class ConteudosWebBll
	{
		public static ConteudoWeb Obter(int webpart)
		{
			using (var contexto = new IntranetContexto())
			{
				return contexto.ConteudosWeb
					.Where(c => c.WebPartId == webpart)
					.SingleOrDefault();
			}
		}

		public static WPConteudosWeb ConverterWebPart(WebPart webpart)
		{
			ConteudoWeb conteudo = Obter(webpart.Id);
			WPConteudosWeb wpconteudo = new WPConteudosWeb(webpart);
			wpconteudo.Url = conteudo.Url;
			wpconteudo.Altura = webpart.Altura;

			return wpconteudo;
		}
	}
}
